package com.core.utils;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class StringUtils {

	public static boolean isNilOrEmpty ( final String value ) {

		if ( value == null ) {
			return true;
		}
		if ( value.trim().length() == 0 ) {
			return true;
		}

		return false;
	}



	public static String md5FromString ( final String value ) {

		String result = null;
		try {
			MessageDigest messageDigest = MessageDigest.getInstance("MD5");
			messageDigest.reset();
			messageDigest.update(value.getBytes());
			byte[] digest = messageDigest.digest();
			BigInteger bigInt = new BigInteger(1, digest);
			result = bigInt.toString(16);
		} catch ( NoSuchAlgorithmException e ) {
			result = null;
		}
		return result;
	}
}
